using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class RateMap : EntityTypeConfiguration<Rate>
    {
        public RateMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Rates");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.RATEBASE1).HasColumnName("RATEBASE1");
            this.Property(t => t.RATEBASE2).HasColumnName("RATEBASE2");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.HIGH_RATEBASE1).HasColumnName("HIGH_RATEBASE1");
            this.Property(t => t.HIGH_RATEBASE2).HasColumnName("HIGH_RATEBASE2");
            this.Property(t => t.LOW_RATEBASE1).HasColumnName("LOW_RATEBASE1");
            this.Property(t => t.LOW_RATEBASE2).HasColumnName("LOW_RATEBASE2");
            this.Property(t => t.SELLING_RATEBASE1).HasColumnName("SELLING_RATEBASE1");
            this.Property(t => t.SELLING_RATEBASE2).HasColumnName("SELLING_RATEBASE2");

            // Relationships
            this.HasRequired(t => t.currency1)
                .WithMany(t => t.Rates)
                .HasForeignKey(d => d.CURRENCY);

        }
    }
}
